/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.prashant.sqlduniya.sqlmanager;

import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author prashant
 */
public class DBNode {

    private List<TableBean> tables = new ArrayList<TableBean>();
    private List<String> schemas;
    private transient PropertyChangeSupport changeSupport = new PropertyChangeSupport(this);

    public List<String> getSchemas() {
        return schemas;
    }

    public void setSchemas(List<String> schemas) {
        Object old = this.schemas;
        this.schemas = schemas;
        changeSupport.firePropertyChange("schemas", old, schemas);
    }

    public List<TableBean> getTables() {
        return tables;
    }

    public void setTables(List<TableBean> tables) {
        Object old = this.tables;
        this.tables = tables;
        changeSupport.firePropertyChange("tables", old, tables);
    }

    public void populateTables(List<String> list,String catalog) {
        tables.clear();
        for (String tbName : list) {
            tables.add(new TableBean(tbName,catalog));
        }
    }

    public void addPropertyChangeListener(PropertyChangeListener listener) {
        changeSupport.addPropertyChangeListener(listener);
    }

    public void removePropertyChangeListener(
            PropertyChangeListener listener) {
        changeSupport.removePropertyChangeListener(listener);
    }
}
